package org.jfunction;

import org.eclipse.jface.text.BadLocationException;
import org.eclipse.jface.text.IDocument;

public class DocumentTextProvider implements TextProvider {

	private final IDocument document;
	private final int offset;
	private final int length;

	public DocumentTextProvider(IDocument document, int offset, int length) {
		this.document = document;
		this.offset = offset;
		this.length = length;
	}
	
	@Override
	public String getText() {
		String text = null;
		try {
			text = document.get(offset, length);
		} catch (BadLocationException e) {
			e.printStackTrace();
		}
		return text;
	}
}